<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.js"></script>
<title>代理网关支付</title>
</head>
<body>
	<input id="payNo" type="" value="${param.payNo}" />
	<input id="sign" type="" value="${param.paySign}" />
	<input id="bizNo" type="" value="${param.bizNo}" />
	<form id="form"  action="" method=post target="_self"></form>
</body>
	<script>
	var payNo = $('#payNo').val();
	var bizNo = $('#bizNo').val();
	var sign = $('#sign').val();
	var terminal_type;
	if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
		//手机地址
		terminal_type='wap';
	}
	else {
		//电脑地址
		terminal_type='web';	
	}
var data= "";
	$.ajax({
		type: "POST",
		url: "http://127.0.0.1:9090/sinopay-web-agentpay/sinopay/agentPay/tongpay.do",//你后台请求URL地址
		dataType:"json",
		data: {"payNo":payNo,"bizNo":bizNo,"sign":sign,"terminal_type":terminal_type},
		success:function(data1){
			//data = JSON.stringify(data1);
			console.log(data1);
			var inputStr="";
			for(var i in data1){
				console.log(i);
				inputStr+="<input type='' id="+i+" name="+i+" value="+data1[i]+">";
		}
			console.log(inputStr);
			$("#form").append(inputStr);
			$.ajax({
				type: "POST",
				url: "http://127.0.0.1:9090/sinopay-web-agentpay/sinopay/agentPay/tconfig.do",//你后台请求URL地址
				dataType:"json",
				success:function(data2){
					$("#form").attr("action",data2.orderUrl);
					function sub(){
						alert("ttt");
						$("#form").submit();
						}
					sub();
				}
				
			})
		},
		error:function(){
			alert(222222);
		}
	})
	</script>
</html>